import Vue from 'vue'
import axios from 'axios'
const instance = axios.create({
  baseURL: 'http://127.0.0.1:8888/api/private/v1/',
  timeout: 5000
})
// 导入进度条
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'


// axios请求拦截器
instance.interceptors.request.use(config => {
  // 网路发起请求调用NProgress.start()
  NProgress.start();
  config.headers.Authorization = window.sessionStorage.getItem('token')
  // 必须return出去
  return config
})
Vue.config.productionTip = false

instance.interceptors.response.use(config => {
  // 请求完成 关闭进度条
  NProgress.done()
  return config
})
export default instance